package com.info.zhiduoduo.common.excelconverter;

import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.property.ExcelContentProperty;
import com.info.zhiduoduo.common.constants.entrustmentproject.EntrustProjectState;

/**
 * 项目状态 1:已创建 2:已分配(受托人创客) 3:支付完成 4:支付失败
 *
 * @author bob
 * @time 2021/11/8 20:53
 */
public class EntrustProjectStateConverter implements Converter<Integer> {

    @Override
    public Class supportJavaTypeKey() {
        return null;
    }

    @Override
    public CellDataTypeEnum supportExcelTypeKey() {
        return null;
    }

    @Override
    public Integer convertToJavaData(CellData cellData, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws Exception {
        return 0;
    }

    @Override
    public CellData convertToExcelData(Integer value, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws Exception {
        if (value == null) {
            return new CellData("");
        } else if (value == EntrustProjectState.CREATED) {
            return new CellData("已创建");
        } else if (value == EntrustProjectState.DISPATCHED) {
            return new CellData("已分配创客");
        } else if (value == EntrustProjectState.FINISH) {
            return new CellData("已完成");
        } else if (value == EntrustProjectState.FAIL) {
            return new CellData("已失败");
        } else {
            return new CellData("");
        }
    }
}
